package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.Evaluate;
import com.nbsaas.boot.evaluate.api.domain.simple.EvaluateSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 评价-列表对象转换器
*/

public class EvaluateSimpleConvert implements Converter<EvaluateSimple, Evaluate> {




@Override
public EvaluateSimple convert(Evaluate source) {
    EvaluateSimple result = new EvaluateSimple();

                result.setNote(source.getNote());

               try {
                   if(source.getCatalog()!=null){
                       result.setCatalog(source.getCatalog().getId());
                   }
                } catch (Exception ignored) { }


                try {
                    if(source.getReplyUser()!=null){
                        result.setReplyUserName(source.getReplyUser().getName());
                    }
                } catch (Exception ignored) { }


                try {
                    if(source.getCreator()!=null){
                        result.setCreatorName(source.getCreator().getName());
                    }
                } catch (Exception ignored) { }

                result.setBusinessId(source.getBusinessId());
                result.setTitle(source.getTitle());
                result.setScore(source.getScore());

                try {
                    if(source.getTargetUser()!=null){
                        result.setTargetUserName(source.getTargetUser().getName());
                    }
                } catch (Exception ignored) { }

                result.setAuditNote(source.getAuditNote());
                result.setReplyContent(source.getReplyContent());
                result.setId(source.getId());
                result.setAuditDate(source.getAuditDate());
                result.setLastDate(source.getLastDate());
                result.setHelpfulCount(source.getHelpfulCount());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                result.setReplyDate(source.getReplyDate());
                result.setAddDate(source.getAddDate());
                result.setTags(source.getTags());

                try {
                    if(source.getCatalog()!=null){
                        result.setCatalogName(source.getCatalog().getName());
                    }
                } catch (Exception ignored) { }

                result.setUnhelpfulCount(source.getUnhelpfulCount());
                if(source.getEvaluateType()!=null){
                   Map<Integer,String> EvaluateTypeMap=new HashMap<>();
                       EvaluateTypeMap.put(1,"商品评价");
                       EvaluateTypeMap.put(2,"服务评价");
                       EvaluateTypeMap.put(3,"用户评价");
                       EvaluateTypeMap.put(4,"文章评价");
                       EvaluateTypeMap.put(5,"其他评价");
                   String label=  EvaluateTypeMap.get(source.getEvaluateType());
                   result.setEvaluateTypeName(label);
                }
                result.setEvaluateType(source.getEvaluateType());

               try {
                   if(source.getReplyUser()!=null){
                       result.setReplyUser(source.getReplyUser().getId());
                   }
                } catch (Exception ignored) { }


                try {
                    if(source.getAuditUser()!=null){
                        result.setAuditUserName(source.getAuditUser().getName());
                    }
                } catch (Exception ignored) { }

                result.setName(source.getName());

               try {
                   if(source.getAuditUser()!=null){
                       result.setAuditUser(source.getAuditUser().getId());
                   }
                } catch (Exception ignored) { }

                if(source.getAnonymous()!=null){
                   Map<Integer,String> AnonymousMap=new HashMap<>();
                       AnonymousMap.put(0,"否");
                       AnonymousMap.put(1,"是");
                   String label=  AnonymousMap.get(source.getAnonymous());
                   result.setAnonymousName(label);
                }
                result.setAnonymous(source.getAnonymous());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());
                result.setBusinessType(source.getBusinessType());

               try {
                   if(source.getTargetUser()!=null){
                       result.setTargetUser(source.getTargetUser().getId());
                   }
                } catch (Exception ignored) { }



    return result;
}

}